def fun(x): # 定义二次函数
    return x**2 -2*x +4

import numpy as np
import matplotlib.pyplot as plt

plt.xticks(np.arange(-10, 11, 1))
plt.yticks(np.arange(-100, 101, 10))

x = np.linspace(-8, 8, num=100)
y = fun(x)
plt.plot(x,y) # 先画出原函数的图形

t=[0]*100
plt.plot(x,t)

laddernum=50
a = np.linspace(-8, 8, num=laddernum)
for i in range(laddernum):
    plt.plot([a[i],a[i]],[0,fun(a[i])],color="black") 

plt.show()

